//
//  AreaCell.m
//  Uhomebk
//
//  Created by Chiang on 2017/11/17.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "AreaCell.h"

@implementation AreaCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUpUI];
    }
    return self;
}

-(void)setUpUI
{
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.selImageView];
    
    [_titleLabel sizeToFit];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.centerY.equalTo(self.contentView.mas_centerY);
    }];
    
    [_selImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_titleLabel.mas_centerY);
        make.right.equalTo(self.contentView.mas_right).offset(-15);
    }];
    
}

-(void)setSelectDic:(NSDictionary *)selectDic
{
    [_titleLabel setText:selectDic[@"areaName"]];
    if ([selectDic[@"sel"] isEqualToString:@"1"]) {//选中状态
        _selImageView.image = [UIImage imageWithContentsOfFile:SEGPicName(@"btn_list_select")];
    } else {
        _selImageView.image = nil;
    }
}

-(UILabel*)titleLabel
{
    if (!_titleLabel) {
        _titleLabel=[[UILabel alloc] init];
        _titleLabel.textColor=kColor_1;
        _titleLabel.font=kFont_14;
    }
    return _titleLabel;
}

-(UIImageView *)selImageView
{
    if (!_selImageView) {
        _selImageView=[[UIImageView alloc] init];
        [_selImageView sizeToFit];
    }
    return _selImageView;
}


@end
